package com.wltjack.springboot.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.wltjack.springboot.service.OrganizationService;
import com.wltjack.springboot.service.UserService;
import com.wltjack.springboot.vo.OrganizationVO;
import com.wltjack.springboot.vo.UserVO;

@Controller
@RequestMapping("/org")
public class OrganizationController {
	private transient final Logger log = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private OrganizationService organizationService;
	
	/**
	 * 组织机构首页
	 */
	@RequestMapping(value = "/index")
	public String index(Model model) throws ServletException, IOException {
		UserVO userVO = userService.getUserDetailById(2);
		model.addAttribute("userVO",userVO);
		model.addAttribute("welcomeMsg", "欢迎您");
		List<OrganizationVO> allOrganizationVOs = organizationService.getAllOrganizations();
		model.addAttribute("allOrganizationVOs",allOrganizationVOs);
		log.info("The properties set to the page is : "+ model.toString());
		return "organization/index";
	}
	
	
	
}
